﻿

function BOX_show(e)
{       //显示
        if(document.getElementById(e)==null){return;}
        BOX_layout(e);
        window.onresize = function(){BOX_layout(e);} //改变窗体重新调整位置
        window.onscroll = function(){BOX_layout(e);} //滚动窗体重新调整位置
}

function BOX_remove(e)
{       //移除
        window.onscroll = null;
        window.onresize = null;
        document.getElementById('BOX_overlay').style.display="none";
        document.getElementById(e).style.display="none";
}

function BOX_layout(e)
{       //调整位置
        var a = document.getElementById(e);
        if (document.getElementById('BOX_overlay')==null){ //判断是否新建遮掩层
            var overlay = document.createElement("div");
            overlay.setAttribute('id','BOX_overlay');
            overlay.onclick=function(){BOX_remove(e);};
            a.parentNode.appendChild(overlay);
        }
        //取客户端左上坐标，宽，高
        var scrollLeft = (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
        var scrollTop = (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
        var clientWidth;
       // if (window.innerWidth) {
        //    clientWidth = ((Sys.Browser.agent === Sys.Browser.Safari) ? window.innerWidth : Math.min(window.innerWidth, document.documentElement.clientWidth));
       // } else {
            //clientWidth = document.documentElement.clientWidth;
            clientWidth = document.body.clientWidth;
       // }
        var clientHeight;
       // if (window.innerHeight) {
      //      clientHeight = ((Sys.Browser.agent === Sys.Browser.Safari) ? window.innerHeight : Math.min(window.innerHeight, document.documentElement.clientHeight));
       // } else {
            //clientHeight = document.documentElement.clientHeight;
            clientHeight = document.body.clientHeight;
       // }
        var bo = document.getElementById('BOX_overlay');
        bo.style.left = scrollLeft+'px';
        bo.style.top = scrollTop+'px';
        bo.style.width = clientWidth+'px';
        bo.style.height = clientHeight+'px';      
        bo.style.display="";
        //Popup窗口定位
        a.style.position = 'absolute';
        a.style.zIndex=101;
        a.style.display="";
        a.style.left = scrollLeft+((clientWidth-a.offsetWidth)/2)+'px';
        a.style.top = scrollTop+((clientHeight-a.offsetHeight)/2)+'px';
}

//function showFriendRequestDialog(userid,username,avatar)
//{
//     var a = document.createElement("script");
//     a.setAttribute('id','AjaxScript');
//     a.type = "text/javascript";
//     a.src = "/support/Alpha/Js/mootools.js";
//     document.getElementsByTagName("BODY")[0].appendChild(a);
//     
//     
//     var e = document.createElement("div");
//     e.setAttribute('id','floatDialog');
//     e.innerHTML = "<div class=\"friendrequestbox\"><h2><span>添加好友</span></h2><div class=\"dialog_body\"><div class=\"friend-request\"><div class=\"avatar\"><img src=\""+avatar+"\" width=\"100px\" height=\"100px\"><p style=\"text-align:center;\">"+username+"</p></div>"+"<div class=\"msg\" id=\"addFriendAlert\">发送好友申请后，对方会收到提示，经对方确认后，你们即可成为好友。<br><br><br><div style=\"display: block;\" id=\"addMsgBox\"><p>添加一条个人信息<font color=\"gray\">（选填）</font>：</p><textarea id=\"addFriendMessage\" name=\"message\" class=\"textarea\" cols=\"30\" rows=\"3\" style=\"width: 270px;\"></textarea></div></div></div></div><div class=\"dialog_buttons\">"
//     +"<input id=\"submitbutton\" value=\"确定\" class=\"input-submit\" type=\"button\" onclick=\"AddFriend("+userid+");\"><input value=\"取消\" class=\"input-submit gray\" type=\"button\" onclick=\"BOX_remove(\'floatDialog\');removeElement();\"></div></div>";
//     document.getElementsByTagName("BODY")[0].appendChild(e);
//     BOX_show('floatDialog');
// }
// 
//function removeElement()
//{

//     var e = document.getElementById('floatDialog');
//     var a = document.getElementById('AjaxScript');
//     document.getElementsByTagName("BODY")[0].removeChild(e);
//     document.getElementsByTagName("BODY")[0].removeChild(a);
//}

//function AddFriend(userid)
//{
//    
//    var msg = $("addFriendMessage").value;
//  
//    if(msg.length > 100 ) 
//    {
//        alert("信息长度不超过100个字！");
//        return;
//    }
//  
//  $("submitbutton").value = "正在处理...";
//  $("submitbutton").disabled = true;
//  var aurl = "/Pages/alpha/User/FriendAdd.aspx"+"?uid="+userid+"&msg="+msg.escUrl();
//  var myAjax=new Ajax(aurl,
//  {
//     method:'post',
//     onComplete:function()
//     {
//              alert(this.response.text);
//              BOX_remove('floatDialog');
//              removeElement();
//      }
//   }
//   );
//   myAjax.request();
//  
//  
//}

///*发送互动*/
//function showActionSendingDialog(userid)
//{
//     var a = document.createElement("script");
//     a.setAttribute('id','AjaxScript');
//     a.type = "text/javascript";
//     a.src = "/support/Alpha/Js/mootools.js";
//     document.getElementsByTagName("BODY")[0].appendChild(a);
//     
//     
//     var e = document.createElement("div");
//     e.setAttribute('id','floatDialog');
//     e.innerHTML ="<form id=\"feedback\" name=\"feedback\"><div class=\"actionsendingbox\"><h2><span>打个招呼</span></h2><table width=\"400px\"><tr>"+
//        "<td><table><tr height=\"35\"><td align=\"center\"><img src=\"/support/common/hugbook/01.gif\"/></td></tr><tr height=\"20\"><td align=\"center\"><span>拥抱</span></td></tr><tr height=\"20\"><td align=\"center\"><input type=\"radio\" class=\"radio\" checked=\"checked\" id=\"face0\" name=\"hugtype\" value=\"0\" /></td></tr></table></td>"+
//        "<td><table><tr height=\"35\"><td align=\"center\"><img src=\"/support/common/hugbook/02.gif\"/></td></tr><tr height=\"20\"><td align=\"center\"><span>祈祷</span></td></tr><tr height=\"20\"><td align=\"center\"><input type=\"radio\" class=\"radio\" id=\"face1\" name=\"hugtype\" value=\"1\" /></td></tr></table></td>"+
//        "<td><table><tr height=\"35\"><td align=\"center\"><img src=\"/support/common/hugbook/03.gif\"/></td></tr><tr height=\"20\"><td align=\"center\"><span>鲜花</span></td></tr><tr height=\"20\"><td align=\"center\"><input type=\"radio\" class=\"radio\" id=\"face2\" name=\"hugtype\" value=\"2\" /></td></tr></table></td>"+
//        "<td><table><tr height=\"35\"><td align=\"center\"><img src=\"/support/common/hugbook/04.gif\"/></td></tr><tr height=\"20\"><td align=\"center\"><span>鼓掌</span></td></tr><tr height=\"20\"><td align=\"center\"><input type=\"radio\" class=\"radio\" id=\"face3\" name=\"hugtype\" value=\"3\" /></td></tr></table></td>"+
//        "<td><table><tr height=\"35\"><td align=\"center\"><img src=\"/support/common/hugbook/05.gif\"/></td></tr><tr height=\"20\"><td align=\"center\"><span>祝你好运</span></td></tr><tr height=\"20\"><td align=\"center\"><input type=\"radio\" class=\"radio\" id=\"face4\" name=\"hugtype\" value=\"4\" /></td></tr></table></td>"+
//        "<td><table><tr height=\"35\"><td align=\"center\"><img src=\"/support/common/hugbook/06.gif\"/></td></tr><tr height=\"20\"><td align=\"center\"><span>与你同在</span></td></tr><tr height=\"20\"><td align=\"center\"><input type=\"radio\" class=\"radio\" id=\"face5\" name=\"hugtype\" value=\"5\" /></td></tr></table></td>"+
//    "</tr></table><div class=\"bor\"><textarea name=\"appendmsg\" cols=\"50\" rows=\"4\" id=\"appendmsg\" class=\"rev_textarea\" style=\"color:rgb(170, 170, 170);\" onfocus=\"OnEnter(this);\" onblur=\"OnExit(this);\">随便说两句....</textarea>"+
//    "</div><p class=\"operator\"><span  id=\"submitbutton\" onmouseout=\"this.className=\'new_sbt\'\" onmouseover=\"this.className=\'new_sbt_h\'\" onclick=\"SendAction("+userid+");\" class=\"new_sbt\">发送</span><span  onmouseout=\"this.className=\'new_sbt\'\" onmouseover=\"this.className=\'new_sbt_h\'\" onclick=\"BOX_remove(\'floatDialog\');removeElement();\" class=\"new_sbt\">取消</span></p></div></form>";
//     document.getElementsByTagName("BODY")[0].appendChild(e);
//     BOX_show('floatDialog');
// }
// 
// function SendAction(userid)
//{
//    
//    var msg = $("appendmsg").value;
//    if(msg == $("appendmsg").defaultValue)  msg="";
//    if(msg.length > 100 ) 
//    {
//        alert("附加信息不能超过100个字！");
//        return;
//    }
//    
//  var actiontype = 0;
//  var form = $('feedback');
//  for(var i = 0;i < form.elements.length;i++)
//  {
//      var e = form.elements[i];
//      if(e.name == "hugtype")
//      {
//         if(e.checked == true)
//         {
//             actiontype = e.value;
//             break;
//         }
//      }
//   }  
//  
//  $("submitbutton").innerText = "正在处理...";
//  $("submitbutton").disabled = true;
//  var aurl = "/Pages/alpha/Ajax/ActionSendAjax.aspx"+"?toUserId="+userid+"&msg="+msg.escUrl()+"&actiontype="+actiontype;
//  var myAjax=new Ajax(aurl,
//  {
//     method:'post',
//     onComplete:function()
//     {
//              alert(this.response.text);
//              BOX_remove('floatDialog');
//              removeElement();
//      }
//   }
//   );
//   myAjax.request();
//  
//  
//}
 

///*发送站内信件*/
//function showMsgSendingDialog(userid)
//{
//     var a = document.createElement("script");
//     a.setAttribute('id','AjaxScript');
//     a.type = "text/javascript";
//     a.src = "/support/Alpha/Js/mootools.js";
//     document.getElementsByTagName("BODY")[0].appendChild(a);
//     
//     
//     var e = document.createElement("div");
//     e.setAttribute('id','floatDialog');
//     e.innerHTML ="<form id=\"feedback\"><div class=\"Msgsendingbox\"><h2><span>发送信息</span></h2><table>"+
//    "<tr><th>提示:</th><td>这是你们之间的私密对话，别人不会看到</td></tr>"+
//    "<tr><th>内容:</th><td><textarea name=\"message\" cols=\"60\" rows=\"5\"  id=\"message\" ></textarea></td></tr>"+
//    
//    "<tr><th>&nbsp;</th><td><p class=\"operator\"><span  id=\"submitbutton\" onmouseout=\"this.className=\'new_sbt\'\" onmouseover=\"this.className=\'new_sbt_h\'\" onclick=\"SendMsg("+userid+");\" class=\"new_sbt\">发送</span><span  onmouseout=\"this.className=\'new_sbt\'\" onmouseover=\"this.className=\'new_sbt_h\'\" onclick=\"BOX_remove(\'floatDialog\');removeElement();\" class=\"new_sbt\">取消</span></p></td></tr>"+
//    "</table></div></form>";
//     document.getElementsByTagName("BODY")[0].appendChild(e);
//     BOX_show('floatDialog');
// }
// 
// 
//  function SendMsg(userid)
//{
//    
//    var message = $("message").value;
//    if(message == "") 
//    {
//        alert("内容不能为空!");
//        return;
//    }
//    
//  
//  $("submitbutton").innerText = "正在处理...";
//  $("submitbutton").disabled = true;
//  var aurl = "/Pages/alpha/Ajax/MsgSendAjax.aspx"+"?toUserId="+userid+"&message="+message.escUrl();
//  var myAjax=new Ajax(aurl,
//  {
//     method:'post',
//     onComplete:function()
//     {
//              alert(this.response.text);
//              BOX_remove('floatDialog');
//              removeElement();
//      }
//   }
//   );
//   myAjax.request();
//  
//  
//}


/*分享日志*/
function showShareLogDialog(lid)
{
     var a = document.createElement("script");
     a.setAttribute('id','AjaxScript');
     a.type = "text/javascript";
     a.src = "/support/Alpha/Js/mootools.js";
     document.getElementsByTagName("BODY")[0].appendChild(a);
     
     
     var e = document.createElement("div");
     e.setAttribute('id','floatDialog');
     e.innerHTML ="<form id=\"feedback\"><div class=\"Msgsendingbox\"><h2><span>分享日志</span></h2><table>"+
    "<tr><th><img src=\"/support/alpha/images/tishi.gif\"/>提示:</th><td>你分享的日志会在好友动态里显示！</td></tr>"+
    "<tr><th>分享理由:</th><td><textarea name=\"message\" cols=\"60\" rows=\"5\"  id=\"message\" style=\"color:rgb(170, 170, 170);\" onfocus=\"OnEnter(this);\" onblur=\"OnExit(this);\">也可以不写</textarea></td></tr>"+
    "<tr><th>&nbsp;</th><td><p class=\"operator\"><span  id=\"submitbutton\" onmouseout=\"this.className=\'new_sbt\'\" onmouseover=\"this.className=\'new_sbt_h\'\" onclick=\"ShareLog("+lid+");\" class=\"new_sbt\">确定</span><span  onmouseout=\"this.className=\'new_sbt\'\" onmouseover=\"this.className=\'new_sbt_h\'\" onclick=\"BOX_remove(\'floatDialog\');removeElement();\" class=\"new_sbt\">取消</span></p></td></tr>"+
    "</table></div></form>";
     document.getElementsByTagName("BODY")[0].appendChild(e);
     BOX_show('floatDialog');
 }
 
 
  function ShareLog(lid)
{
   
   var msg = $("message").value;
    if(msg == $("message").defaultValue)  msg="";
    if(msg.length > 100 ) 
    {
        alert("输入理由不能超过100个字！");
        return;
    }
  
  $("submitbutton").innerText = "正在处理...";
  $("submitbutton").disabled = true;
  var aurl = "/Pages/alpha/Ajax/ShareLog.aspx"+"?lid="+lid+"&message="+msg.escUrl();
  var myAjax=new Ajax(aurl,
  {
     method:'post',
     onComplete:function()
     {
              alert(this.response.text);
              BOX_remove('floatDialog');
              removeElement();
      }
   }
   );
   myAjax.request();
  
  
}




/*分享帖子*/
function showShareBBSTopicDialog(id)
{
     var a = document.createElement("script");
     a.setAttribute('id','AjaxScript');
     a.type = "text/javascript";
     a.src = "/support/Alpha/Js/mootools.js";
     document.getElementsByTagName("BODY")[0].appendChild(a);
     
     
     var e = document.createElement("div");
     e.setAttribute('id','floatDialog');
     e.innerHTML ="<form id=\"feedback\"><div class=\"Msgsendingbox\"><h2><span>分享帖子</span></h2><table>"+
    "<tr><th><img src=\"/support/alpha/images/tishi.gif\"/>提示:</th><td>你分享的帖子会在好友动态里显示！</td></tr>"+
    "<tr><th>分享理由:</th><td><textarea name=\"message\" cols=\"60\" rows=\"5\"  id=\"message\" style=\"color:rgb(170, 170, 170);\" onfocus=\"OnEnter(this);\" onblur=\"OnExit(this);\">也可以不写</textarea></td></tr>"+
    "<tr><th>&nbsp;</th><td><p class=\"operator\"><span  id=\"submitbutton\" onmouseout=\"this.className=\'new_sbt\'\" onmouseover=\"this.className=\'new_sbt_h\'\" onclick=\"ShareBBSTopic("+id+");\" class=\"new_sbt\">确定</span><span  onmouseout=\"this.className=\'new_sbt\'\" onmouseover=\"this.className=\'new_sbt_h\'\" onclick=\"BOX_remove(\'floatDialog\');removeElement();\" class=\"new_sbt\">取消</span></p></td></tr>"+
    "</table></div></form>";
     document.getElementsByTagName("BODY")[0].appendChild(e);
     BOX_show('floatDialog');
 }
 
 
  function ShareBBSTopic(id)
{
   
   var msg = $("message").value;
    if(msg == $("message").defaultValue)  msg="";
    if(msg.length > 100 ) 
    {
        alert("输入理由不能超过100个字！");
        return;
    }
  
  $("submitbutton").innerText = "正在处理...";
  $("submitbutton").disabled = true;
  var aurl = "/Pages/alpha/Ajax/ShareBBSTopic.aspx"+"?tid="+id+"&message="+msg.escUrl();
  var myAjax=new Ajax(aurl,
  {
     method:'post',
     onComplete:function()
     {
              alert(this.response.text);
              BOX_remove('floatDialog');
              removeElement();
      }
   }
   );
   myAjax.request();
  
  
}

/*分享用户*/
function showShareUserDialog(id)
{
     var a = document.createElement("script");
     a.setAttribute('id','AjaxScript');
     a.type = "text/javascript";
     a.src = "/support/Alpha/Js/mootools.js";
     document.getElementsByTagName("BODY")[0].appendChild(a);
     
     
     var e = document.createElement("div");
     e.setAttribute('id','floatDialog');
     e.innerHTML ="<form id=\"feedback\"><div class=\"Msgsendingbox\"><h2><span>分享用户</span></h2><table>"+
    "<tr><th><img src=\"/support/alpha/images/tishi.gif\"/>提示:</th><td>你分享的用户会在好友动态里显示！</td></tr>"+
    "<tr><th>分享理由:</th><td><textarea name=\"message\" cols=\"60\" rows=\"5\"  id=\"message\" style=\"color:rgb(170, 170, 170);\" onfocus=\"OnEnter(this);\" onblur=\"OnExit(this);\">也可以不写</textarea></td></tr>"+
    "<tr><th>&nbsp;</th><td><p class=\"operator\"><span  id=\"submitbutton\" onmouseout=\"this.className=\'new_sbt\'\" onmouseover=\"this.className=\'new_sbt_h\'\" onclick=\"ShareUser("+id+");\" class=\"new_sbt\">确定</span><span  onmouseout=\"this.className=\'new_sbt\'\" onmouseover=\"this.className=\'new_sbt_h\'\" onclick=\"BOX_remove(\'floatDialog\');removeElement();\" class=\"new_sbt\">取消</span></p></td></tr>"+
    "</table></div></form>";
     document.getElementsByTagName("BODY")[0].appendChild(e);
     BOX_show('floatDialog');
 }
 
 
  function ShareUser(id)
{
   
   var msg = $("message").value;
    if(msg == $("message").defaultValue)  msg="";
    if(msg.length > 100 ) 
    {
        alert("输入理由不能超过100个字！");
        return;
    }
  
  $("submitbutton").innerText = "正在处理...";
  $("submitbutton").disabled = true;
  var aurl = "/Pages/alpha/Ajax/ShareUser.aspx"+"?uid="+id+"&message="+msg.escUrl();
  var myAjax=new Ajax(aurl,
  {
     method:'post',
     onComplete:function()
     {
              alert(this.response.text);
              BOX_remove('floatDialog');
              removeElement();
      }
   }
   );
   myAjax.request();
  
  
}



function suckerfish(type, tag, parentId) {
	if (window.attachEvent) {
		window.attachEvent("onload", function() {
			var sfEls = (parentId==null)?document.getElementsByTagName(tag):document.getElementById(parentId).getElementsByTagName(tag);
			type(sfEls);
		});
	}
}

hover = function(sfEls)
 {
	for (var i=0; i<sfEls.length; i++) 
	{
		sfEls[i].onmouseover=function() 
		{
			this.className+=" hover";
			if(this.id=="treatment")
			{
			   var e = document.getElementById("treatment_menu");
			   e.style.display = "block";
			}	
			if(this.id=="bbs")
			{
			   var e = document.getElementById("bbs_menu");
			   e.style.display = "block";
			}	
		}
			
		sfEls[i].onmouseout=function() 
		{
			this.className=this.className.replace(new RegExp(" hover\\b"), "");
			if(this.id=="treatment")
			{
			   var e = document.getElementById("treatment_menu");
			   e.style.display = "none";
			}	
			if(this.id=="bbs")
			{
			   var e = document.getElementById("bbs_menu");
			   e.style.display = "none";
			}	
		}
	}
 }
suckerfish(hover, "li");

